#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main()
{
    int arr1[1000];
    int arr2[1000];
    int n = 0, m = 0;
    scanf("%d %d", &n, &m);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &arr1[i]);
    }
    for (int i = 0; i < m; i++)
    {
        scanf("%d", &arr2[i]);
    }
    int i = 0, j = 0, index = 0;
    int arr3[2000];
    while (i < n && j < m)
    {
        if (arr1[i] < arr2[j])
        {
            arr3[index] = arr1[i];
            index++;
            i++;
        }
        else
        {
            arr3[index] = arr2[j];
            index++;
            j++;
        }
    }
    while (i < n)
    {
        arr3[index] = arr1[i];
        i++;
        index++;
    }
    while (j < m)
    {
        arr3[index] = arr2[j];
        j++;
        index++;
    }
    for (index = 0; index < n + m; index++)
    {
        printf("%d ", arr3[index]);
    }
    return 0;
}

